" Vim syntax file
"

if version < 600
    syntax clear
elseif exists("b:current_syntax")
    finish
endif

setlocal iskeyword+=?,-,*,!,+,/,=,<,>,.,:,$

syntax keyword qpConstant nil
syntax keyword qpBoolean t
syntax keyword qpSpecial do fct if let quote while setq return yield each recur break continue call/cc setf with
syntax keyword qpException raise try
syntax keyword qpCond if when unless if-not
syntax keyword qpDefine defct defmac defvar defalias defconst defmeth deftype
syntax keyword qpMacro and or
syntax keyword qpFunc * + - / = < <= > >= not symbol-p str str-p kword-p int-p fct-p print puts str eval list list-p array array-p table table-p tuple tuple-p cons concat count apply map atom-p car cdr cadr cddr list* != gensym use coro-p caar cdar cons-p nreverse len char-p float-p bvector-p pkg-p is
syntax keyword qpVariable *out* *in* *err* *argv*

" Keywords are symbols:
"   static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^/]].*/)?([\\D&&[^/]][^/]*)");
" But they:
"   * Must not end in a : or /
"   * Must not have two adjacent colons except at the beginning
"   * Must not contain any reader metacharacters except for ' and #
syntax match qpKeyword "\v:{1,2}%([^ \n\r\t()\[\]{}";@^`~\\%/]+/)*[^ \n\r\t()\[\]{}";@^`~\\%/]+:@<!"

syntax region qpString start=/L\="/ skip=/\\\\\|\\"/ end=/"/

let s:radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
for s:radix in range(2, 36)
    execute 'syntax match qpNumber "\c\<-\?' . s:radix . 'r[' . strpart(s:radixChars, 0, s:radix) . ']\+\>"'
endfor
unlet! s:radixChars s:radix

syntax match qpNumber "\<-\=[0-9]\+\(\.[0-9]*\)\=\(M\|\([eE][-+]\?[0-9]\+\)\)\?\>"
syntax match qpNumber "\<-\=[0-9]\+N\?\>"
syntax match qpNumber "\<-\=0[xb][0-9a-fA-F]\+\>"
syntax match qpNumber "\<-\=[0-9]\+/[0-9]\+\>"

syntax match qpQuote "'"
syntax match qpQuote "`"
syntax match qpUnquote "\,"
syntax match qpUnquote "\,@"

syntax match qpComment ";.*$" contains=qpTodo,@Spell

syntax keyword qpTodo contained FIXME XXX TODO FIXME: XXX: TODO:

syntax region qpSexp   matchgroup=qpParen start="("  matchgroup=qpParen end=")"  contains=TOP,@Spell
syntax region qpVector matchgroup=qpParen start="\[" matchgroup=qpParen end="\]" contains=TOP,@Spell
syntax region qpMap    matchgroup=qpParen start="{"  matchgroup=qpParen end="}"  contains=TOP,@Spell

" Highlight superfluous closing parens, brackets and braces.
syntax match qpError "]\|}\|)"

syntax sync fromstart

if version >= 600
    command -nargs=+ HiLink highlight default link <args>
else
    command -nargs=+ HiLink highlight link <args>
endif

HiLink qpConstant  Constant
HiLink qpBoolean   Boolean
HiLink qpKeyword   Constant
HiLink qpNumber    Number
HiLink qpString    String

HiLink qpVariable  Identifier
HiLink qpCond      Conditional
HiLink qpDefine    Special
HiLink qpException Exception
HiLink qpFunc      Function
HiLink qpMacro     Special

HiLink qpSpecial   Special
HiLink qpVarArg    Special
HiLink qpQuote     SpecialChar
HiLink qpUnquote   SpecialChar
HiLink qpMeta      SpecialChar
HiLink qpDeref     SpecialChar

HiLink qpComment   Comment
HiLink qpTodo      Todo

HiLink qpError     Error

HiLink qpParen     Delimiter

delcommand HiLink

let b:current_syntax = "kp"

